//package com.bff.gaia.runtime.maqy.util;
//
//import com.esotericsoftware.minlog.Log;
//import com.bff.gaia.runtime.maqy.service.NetStat;
//import com.bff.gaia.runtime.maqy.service.NetStatRetriveService;
//import com.bff.gaia.runtime.maqy.service.Rate;
//
///**
// * add by HFY.
// */
//public class NetUtil {
//	// 计算当前上传下载速度，这里计算的实际上是系统即时吞吐量，并非最大上下行带宽
//	public static Rate getCurrentRate() throws Exception {
//		NetStat[] latestStats = NetStatRetriveService.getLatestStats();
//		int length = NetStatRetriveService.STAT_NUM;
//		NetStat oldStat = latestStats[length - 2];
//		NetStat newStat = latestStats[length - 1];
//		long intervalReceiveBytes = newStat.getrBytes() - oldStat.getrBytes();
//		long intervalTransmitBytes = newStat.gettBytes() - oldStat.gettBytes();
//		int interval = NetStatRetriveService.INTERVAL;
//
//		Log.info("hfy", String.format("[NetUtil] intervalReceiveBytes-%d, intervalTransmitBytes-%d.", intervalReceiveBytes, intervalTransmitBytes));
//
//		double upRate = ((double) intervalTransmitBytes / (1024 * 1024)) / (interval / 1000); // MB/s
//		double downRate = ((double) intervalReceiveBytes / (1024 * 1024)) / (interval / 1000); // MB/s
//
//		return new Rate(upRate, downRate);
//	}
//}